Split string into smaller part with constrain [PHP RegEx HTML]

Posted by Sadi on Stack Overflow See other posts from Stack Overflow or by Sadi
Published on 2010-04-28T09:40:45Z Indexed on 2010/04/28 9:43 UTC
Read the original article Hit count: 256

Hello,

I need to split long string into a array with following constrains:

  • Each part will have a limited number of character (e.g. not more than 8000 character)
  • Each part can contain multiple sentences (delimited by . [full stop]) but never a partial sentences. Except if the last part of the string (as last part may not have any full stop.
  • The string may contain HTML tags. But the tag can not be divided as ( to ). That means HTML tag should be intact. But starting tag and ending tag can be stay on different segment/chunk.

I think regular expression with preg_split can do it. Would please help me with the proper RegEx.

Thank you Sadi

© Stack Overflow or respective owner

Related posts about php

Related posts about split